//
//  AXFCarouselCollectionViewCell.m
//  AXFEightGroup
//
//  Created by ooops on 12/28/16.
//  Copyright © 2016 ya. All rights reserved.
//

#import "AXFCarouselCollectionViewCell.h"

@implementation AXFCarouselCollectionViewCell {
    NSMutableArray *_cycleImageArray;
    NSMutableArray *_cycleDescpArray;
}

//走先
- (instancetype)initWithFrame:(CGRect)frame {
    if(self = [super initWithFrame:frame]) {
        //SNSLog(@"%s",__func__);
        _cycleImageArray = [NSMutableArray array];
        _cycleDescpArray = [NSMutableArray array];
    }
    return self;
}

//走后
- (void)setModels:(NSArray<AXFDataModel *> *)models {
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        _models = models;
        [models enumerateObjectsUsingBlock:^(AXFDataModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
            [_cycleImageArray addObject:obj.imgURL];
            [_cycleDescpArray addObject:obj.name];
            
            _carouselView = [[XRCarouselView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, ScrollViewHeight)];
            _carouselView.imageArray = _cycleImageArray;
            _carouselView.describeArray = _cycleDescpArray;
            
            _carouselView.pagePosition = PositionBottomRight;
            //carouselView.delegate = self;
            _carouselView.time = 2;
            
            //设置分页控件的图片,不设置则为系统默认
            [_carouselView setPageImage:[UIImage imageNamed:@"other"] andCurrentPageImage:[UIImage imageNamed:@"current"]];
            [self addSubview:_carouselView];
        }];
    });
}



@end
